
import { ref, watch, reactive, getCurrentInstance } from "vue"
import { Plus } from '@element-plus/icons-vue'
import request from '@/utils/request'
import $button from '@/button'
export function resetApi(dataRequest) {
    return request({
        url: "sale/reset/" + dataRequest,
        method: "PUT",
    });
}
export function updateApi(dataRequest) {
    return request({
        url: "sale",
        method: "PUT",
        data: dataRequest
    });
}
export function addApi(dataRequest) {
    return request({
        url: "/sale/saleRoot/add",
        method: "POST",
        data: dataRequest
    });
}
export function getCodeUrlApi(id) {
    return request({
        url: "/sale/invitation/code/url/" + id,
        method: "GET"
    });
}
//
export const tableItem = reactive({
    select: false,//多选框
    loading: false,
    index: !true,//顺序
    expandAll: false,//树形默认展开
    tree: true,//树形
    align: 'center',
    column: [
        {
            label: '销售编号',
            prop: 'num',
        },
        {
            label: '姓名',
            prop: 'name',
        },
        {
            label: '手机号',
            prop: 'mobile',
        },
        {
            label: '身份证号',
            prop: 'idCard',
        },
        {
            label: '创建日期',
            prop: 'registerTime',
        },
        {
            label: '操作',
            prop: 'action',
        }
    ],
    pageInfo: {
        request: {
            "name": "", //姓名
            "mobile": "", //电话号码
            "idCard": "", //身份证号
            "num": "", //身份标识
            "typeCode": "root", //销售标识： “root”-销售 “sale”-商家
            "disabledFlag": 0, //0-正常 1-禁用
            "parentId": "", //上级商家
            "pageDomain": {
                "pageNum": 1,//分页页面数
                "pageSize": 10,//分页页面数据大小
                "orderByColumn": "",
                "isAsc": "",
                "reasonable": ""
            }
        },
        url: '/sale/paging',//分页路由，不传的话需要传入自定义的分页函数paging 传入时定义的分页函数paging会失效
        method: 'POST',//分页请求方法，不传默认为POST
        // 分页函数paging
        paging: function () { }
    },
    tableData: {
        total: '',//分页总计
        // 分页数据
        data: []
    },
    // 操作栏按钮
    btnArray: []
})
export const operationItem = reactive({
    defaultSearch: true,//默认搜索按钮
    SearchText: '查询',
    defaultRefresh: false,//默认重置按钮
    customTableHeader: false,//
    SearchItem: [
        {
            code: "sale",
            name: "销售编号/姓名",
            type: "input",
        },
        {
            code: "mobile",
            name: "手机号",
            type: "input",
        },
        {
            code: "idCard",
            name: "身份证号",
            type: "input",
        }, {
            code: ["registerDateStart",
                "registerDateEnd",],
            startName: "创建日期", //默认是开始时间 type为 daterange生效
            rangeName: "", //默认是至 type为 daterange生效
            endName: "创建日期", //默认是结束时间 type为 daterange生效
            valueFormat: "", //默认是YYYY-MM-DD
            placeholder: "请选择日期", //默认是请选择日期type为date生效
            type: "daterange", //daterange或date
        },
    ],
    menuArray: [
        {
            show: true,
            type: 'primary',
            text: '新增销售',
            hasPermi: [$button.coursesaleadd || null],
            icon: Plus,
            customParameters: 'add',//自定义函数参数
            handle: () => {
                console.log('handle')
            }
        },
    ]
})
